package Ontology;

import dbcontext.HierarchyTable;

/**
 * 
 * @author michael
 * The class presets a structure containing hierarchical relation
 *
 */
public class WDHier
{
    private int iClass1ID;			//	Identifier of parent class
    private int iClass2ID;			//	Identifier of child class
    private boolean bIsMarked;		//	Is marked?
    private boolean bIsInherited;	//	Is inherited?
    private int iFatherClassID;		//	Class ID the relation is inherited from
    private int iCardMin;
    private int iCardMax;
    private int iIDFromDB;

    public WDHier( int iiClass1ID, int iiClass2ID, boolean ibIsInherited, int iiFatherClassID, int iiCardMin, int iiCardMax, int iiIDFromDB )
    {
    	iClass1ID = iiClass1ID;
    	iClass2ID = iiClass2ID;
    	bIsInherited = ibIsInherited;
    	iFatherClassID = iiFatherClassID;
    	iCardMin = iiCardMin;
    	iCardMax =iiCardMax; 
    	iIDFromDB = iiIDFromDB;
    }

    public String toString() 
    {
        return "Class1ID: " + iClass1ID + "; Class2ID: " + iClass2ID + "; Is inherited: " + bIsInherited + "; Father class ID: " + iFatherClassID;
    }
    public String toFileWithTab() 
    {
        return "" + iClass1ID + "\t" 
        	+ iClass2ID + "\t"
        	+ ( bIsInherited ? "T" : "F" );
    }
    /** Stores data to the table 'hierarchy' */
    public void toDatabase(java.sql.Connection conn)
    {
        HierarchyTable.insert(conn, iClass1ID, iClass2ID);
    }

    public int getClass1ID() 
    {
        return iClass1ID;
    }
    public int getClass2ID() 
    {
        return iClass2ID;
    }
    public boolean getIsInherited() 
    {
        return bIsInherited;
    }
    public boolean getIsMarked() 
    {
        return bIsMarked;
    }
    public int getFatherClassID() 
    {
        return iFatherClassID;
    }
    public int getCardMin() 
    {
        return iCardMin;
    }
    public int getCardMax() 
    {
        return iCardMax;
    }
    public int getIDFromDB() 
    {
        return iIDFromDB;
    }
    
    public void setIsMarked( boolean ibIsMarked ) 
    {
        bIsMarked = ibIsMarked;
        return;
    }
    public void setInheritedClassID( int iiFatherClassID ) 
    {
    	iFatherClassID = iiFatherClassID;
    	bIsInherited = true;
        return;
    }
    public void setIsNotInherited( ) 
    {
    	iFatherClassID = iClass1ID;
    	bIsInherited = false;
        return;
    }
}